<?php

namespace App\Models\Order;

use App\Models\BasicModel;
use App\Models\CompanyDepartment\DepartmentModel;

class OrderSubModel extends BasicModel
{
    protected $table = 'orders_sub';

    protected $primaryKey = 'orders_sub_id';

    protected $fillable = [
        'order_sub_id',
        'order_id',
        'goods_id',
        'product_name',
        'product_price',
        'product_quantity',
        'created_at',
        'updated_at'
    ];

    protected $casts = [
        'order_sub_id' => 'integer',
        'order_id' => 'integer',
        'goods_id' => 'integer',
        'product_name' => 'string',
        'product_price' => 'decimal:2',
        'product_quantity' => 'integer',
        'created_at' => 'string',
        'updated_at' => 'string'
    ];

    protected $hidden = [
        'created_at',
        'updated_at'
    ];

    public function order()
    {
        return $this->belongsTo(OrderModel::class,'order_id','order_id');
    }
}
